COMPILE_FLAG = -c -fPIC -O2 -Wall -std=gnu++11
libmrpcv2.so : minirpc.o libmrpc.so
	g++ -shared -fPIC -o libmrpcv2.so minirpc.o -lmrpc -O0 -g -std=gnu++11 -lstdc++ -L.

minirpc.o : minirpc.cc MiRpc.h
	g++ ${COMPILE_FLAG} minirpc.cc 

Server : Server.cc libmrpc.so
	g++ Server.cc -o Server -L. -lpthread -lmrpc -O2 -std=gnu++11

Client : Client.cc libmrpc.so
	g++ Client.cc -o Client -L. -lmrpc -O2 -std=gnu++11

libmrpc.so: MiRpc.o Session.o Cycles.o MemoryManager.o Rdma.o 
	g++ -shared -fPIC -o libmrpc.so MiRpc.o Session.o Cycles.o MemoryManager.o Rdma.o -libverbs -lstdc++

MiRpc.o : MiRpc.cc MiRpc.h
	g++ ${COMPILE_FLAG} MiRpc.cc 

Session.o : Session.cc Session.h MemoryManager.h Rdma.h
	g++ ${COMPILE_FLAG} Session.cc 

MemoryManager.o : MemoryManager.cc MemoryManager.h
	g++ ${COMPILE_FLAG} MemoryManager.cc

Rdma.o : Rdma.cc Rdma.h
	g++ ${COMPILE_FLAG} Rdma.cc 

Cycles.o : Cycles.h Cycles.cc
	g++ ${COMPILE_FLAG} Cycles.cc


.PHONY : clean
clean : 
	rm -rf *.o *.so Client Server


.PHONY : all
all : 
	make libmrpcv2.so Server Client 
